package com.lineage.data.item_etcitem;

import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Auto_Points extends ItemExecutor {
  private static final Log _log = LogFactory.getLog(Auto_Points.class);
  
  private int _points;
  
  public static ItemExecutor get() {
    return new Auto_Points();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    if (item == null)
      return; 
    if (pc == null)
      return; 
    pc.get_other().set_Auto_Points(pc.get_other().get_Auto_Points() + this._points);
    pc.sendPackets((ServerBasePacket)new S_SystemMessage("您的可挂机时间已经充值 " + this._points + " 秒钟"));
    int time = pc.get_other().get_Auto_Points();
    pc.sendPackets((ServerBasePacket)new S_SystemMessage("您目前可挂机剩余时间为 " + time + " 秒钟"));
    pc.getInventory().removeItem(item, 1L);
    try {
      pc.save();
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } 
  }
  
  public void set_set(String[] set) {
    try {
      this._points = Integer.parseInt(set[1]);
    } catch (Exception exception) {}
  }
}
